package com.autumn.scheduler.api.constant;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 常量项目
 * 
 * @author 老码农
 *
 *         2018-03-30 16:56:41
 */
public class ConstantItem<T> implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -3400754266278775576L;
	private T value;
	private String name;

	/**
	 * 
	 * @param map
	 * @return
	 *
	 */
	public static <E> List<ConstantItem<E>> createItems(Map<E, String> map) {
		List<ConstantItem<E>> items = new ArrayList<>();
		if (map != null) {
			for (Map.Entry<E, String> m : map.entrySet()) {
				ConstantItem<E> item = new ConstantItem<E>(m.getKey(), m.getValue());
				items.add(item);
			}
		}
		return items;
	}

	public ConstantItem() {

	}

	public ConstantItem(T value, String name) {
		this.value = value;
		this.name = name;
	}

	public T getValue() {
		return value;
	}

	public void setValue(T value) {
		this.value = value;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
